<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>首页</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
    <!-- <link rel="stylesheet" type="text/css" href="../css/style.css" /> -->
    <link rel="stylesheet" type="text/css" href="../css/aui-slide.css" />
    <style>
        .aui-bar-nav {
            background-color: #FFF;
            color: #000;
        }

        .tod_os {
            display: flex;
        }

        .tod_text {
            position: relative;
            /*left: -28px*/
        }

        #aui-slide2 {
            width: 200px;
        }

        #aui-slide3 {
            width: 100%;
        }

        .scrollDiv {
            width: 340px;
            height: 40px;
            margin: auto;
        }

        .scrollDiv>div {
            width: 240px;
            height: 40px;
            overflow: hidden;
        }

        .scrollDiv ul {
            height: 200px;
            position: relative;
            animation: dh 9s infinite 3s;
            box-sizing: border-box;
        }

        @keyframes dh {
            0% {
                transform: translatey(0px);
            }
            10% {
                transform: translatey(-40px);
            }
            33% {
                transform: translatey(-40px);
            }
            42% {
                transform: translateY(-80px);
            }
            67% {
                transform: translateY(-80px);
            }
            76% {
                transform: translateY(-120px);
            }
            100% {
                transform: translateY(-120px);
            }
        }

        .scrollDiv ul>li {
            width: 260px;
            height: 40px;
            line-height: 40px;
        }

        .scrollDiv ul span {
            font-size: 13px;
            color: #666666;
            width: 160px;
        }

        .tod_os>div:nth-child(1) {
            width: 120px;
            line-height: 40px;
        }

        .tod_os_a {
            display: flex;
            height: 40px;
            line-height: 40px;
        }

        .tod_os_a img {
            width: 16px;
            height: 16px;
            margin-top: 10px;
        }

        .right {
            display: flex;
            align-items: center;
            box-sizing: border-box;
            padding-left: 5px;
        }

        .right>span:first-child {
            width: 20px;
            height: 20px;
            line-height: 21px;
            text-align: center;
            border-radius: 50%;
            background: #F74C5C;
            color: #fff;
            font-size: 11px;
            margin-right: 5px;
        }

        .top>div:first-child {
            color: #fff;
            margin-left: 20px;
            font-size: 15px;
        }

        .index {
            width: 100%;
            box-sizing: border-box;
            padding: 0 10px;
        }

        .index .top-box {
            padding: 3% 1px;
            height: 7rem;
            width: 100%;
            background-image: url(../image/3.png);
            background-size: 100% 100%;
            border-radius: 15px;
        }

        .index .top-box .row {
            display: flex;
            width: 100%;
            justify-content: space-between;
        }

        .index .top-box .top {
            padding-top: 0.4rem;
            justify-content: space-between;
            align-items: center;
        }

        .index .top-box .top img {
            width: 2rem;
            height: 2rem
        }

        .index .top-box .top .right {
            width: 5rem;
            height: 1.6rem;
            line-height: 1.6rem;
            text-align: center;
            font-size: 0.75rem;
            color: #F3345A;
            background: rgba(255, 255, 255, 1);
            border-radius: 0.8rem 0 0 0.8rem;
        }

        .index .top-box>h2 {
            text-align: left;
            margin-left: 20px;
            font-size: 1.8rem;
            color: #FFF;
        }

        .index .top-box>p {
            font-size: 0.7rem;
            text-align: center;
            color: #FFDBA2;
        }

        .index .top-box .bottom {
            color: #FFDBA3;
            font-size: 0.75rem;
            align-items: center;
        }

        .index .top-box .bottom>div {
            width: 50%;
            text-align: center;
        }

        .index .top-box .bottom>div:first-child {
            border-right: 1px solid #FFF;
        }

        .index .top-box .bottom span {
            color: #FFF;
        }

        .index .content>h3 {
            font-size: 0.85rem;
            font-weight: bold;
            color: #333;
        }

        .index .content>div {
            display: flex;
            height: 10rem;
            justify-content: space-between;
            width: 100%;
            box-sizing: border-box;
        }

        .index .content .top {
            width: 37%;
            background-image: url(../image/4.png);
            background-size: 100% 100%;
            background-repeat: no-repeat;
            height: 10rem;
            box-sizing: border-box;
            padding: 20px 0 0 0;
        }

        .top+div {
            width: 60%;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            align-items: center;
            color: #fff;
        }

        .top+div>div {
            box-sizing: border-box;
            position: relative;
            padding: 15px 10px 15px 20px;
        }

        .top+div>div img {
            width: 60px;
            position: absolute;
            top: 20px;
            right: 15px;
        }

        .top+div>div h3 {
            font-size: 17px;
            font-weight: bold;
        }

        .top+div>div h3+p {
            color: #fff;
            font-size: 14px;
            margin-top: 10px;
        }

        .right_t {
            height: 47%;
            width: 100%;
            border-radius: 15px;
            background: -webkit-linear-gradient(right, #8328E9 0%, #A167FC 100%);
        }

        .right_b {
            height: 47%;
            width: 100%;
            border-radius: 15px;
            background: -webkit-linear-gradient(right, #478EEE 0%, #6358EF 100%);
        }

        .index .content .top>h3 {
            position: relative;
            font-size: 1rem;
            color: #fff;
            margin-bottom: 0.6rem;
            font-weight: bold;
            width: 100%;
            text-align: center;
        }

        .index .content .top>h3+p {
            height: 26px;
            width: 50%;
            margin: auto;
            border-radius: 13px;
            text-align: center;
            line-height: 26px;
            background: #fff;
            color: #FFC51E;
            margin-top: 5px;
        }
        /*.index .content .top>h3:before{
          content: '';
          position: absolute;
          top: 50%;
          transform: translateY(-50%);
          width: 0.2rem;
          height: 1rem;
          border-radius: 0.1rem;
          background-color: #CFD9FF;
          left: -0.6rem;
        }*/

        .index .content .top>p {
            font-size: 0.8rem;
            color: #CFD9FF;
        }

        .index .content .bottom {
            margin-top: 1rem;
            display: flex;
            justify-content: space-between;
            width: 100%;
            background-image: url(../image/zu3.png);
            background-size: 100% 100%;
            border-radius: 15px;
            height: 6rem;
            box-sizing: border-box;
            padding-right: 20px;
            align-items: center;
        }

        .index .content .bottom>div {
            border-radius: 0.2rem;
        }
        /*.index .content .bottom>div:first-child{
          background-image: url(../image/51.png);
          background-size: 100% 100%;
          box-shadow: 0 0 18px rgba(255, 126, 82,0.8);
        }*/

        .index .content .bottom>div:last-child {
            background-image: url(../image/61.png);
            background-size: 100% 100%;
            box-shadow: 0 0 18px rgba(255, 102, 113, 0.8);
        }

        .index .content .bottom h3 {
            font-size: 1rem;
            color: #fff;
            padding-left: 1.2rem;
            font-weight: bold;
            position: relative;
        }

        .index .content .bottom span {
            padding-left: 1.2rem;
            display: block;
            margin-top: 20px;
            color: #fff;
        }

        .index .content .bottom img {
            width: 70px;
        }
    </style>
</head>

<body>
    <div id="app">
        <header id="header" data-color="dark" class="aui-bar aui-bar-nav">五花牛试玩</header>
        <div class="aui-content index">
            <div class="top-box">
                <div class="row top">
                    <div tapmode onclick="openWin('home')">今日收益</div>
                    <div tapmode onclick="openWin('home')" class="right">
                        <span>￥</span><span>立即提现</span>
                    </div>
                </div>
                <h2 id="tod_money">0.00</h2>
                <div class="row bottom" id="money">
                    <div>累计收益：<span>0.00元</span></div>
                    <div>账户余额：<span>0.00元</span></div>
                </div>
            </div>
            <div class="tod_os">
                <!-- <div v-for="(item,index) in os_list" :key="index">
                        {{item.notice_title}}
                      </div> -->
                <div class="tod_os_a">
                    <img src="../icon/lab.png" alt="">系统公告:
                </div>
                <div class="scrollDiv">
                    <div>
                        <ul>
                            <li v-for="item in oslist" @click="gettolist(item.id)">
                                <span>{{item.notice_title}}</span>
                            </li>
                        </ul>
                    </div>
                </div>

            </div>
            <div class="content">
                <h3>任务试玩</h3>
                <div>
                    <div class="top" tapmode onclick="opentrWin()">
                        <h3>试玩赚钱</h3>
                        <p>去赚钱</p>
                    </div>
                    <div>
                        <div class="right_t" tapmode onclick="openWin('rec')">

                            <div>
                                <h3>邀请好友</h3>
                                <p>最多贡献20元</p>
                            </div>
                            <img src="../image/1.png" alt="">
                        </div>
                        <div class="right_b" tapmode onclick="gogame()">
                            <h3>游戏任务</h3>
                            <p>去做任务</p>
                            <img src="../image/2.png" alt="">
                        </div>
                    </div>
                </div>

                <div class="bottom" tapmode onclick="openMq()">
                    <div>
                        <h3>联系客服</h3>
                        <span>有问题找客服...</span>
                    </div>
                    <img src="../image/5_.png" alt="">
                </div>
            </div>
        </div>
    </div>
    </div>
</body>
<script type="text/javascript" src="../script/vue.js"></script>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript" src="../script/meiqia.js"></script>
<script type="text/javascript" src="../script/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="../script/md5.min.js"></script>
<script type="text/javascript" src="../script/jquery.base64.js"></script>
<script type="text/javascript" src="../script/aui-slide.js"></script>
<script type="text/javascript">
    var countdown = 60,
        udid_ = '',
        MtId_, AppKey_, MtIDUser_,
        idfa_; //

    apiready = function() {
        vm = new Vue({
            el: "#app",
            data: {
                oslist: ""

            },
            methods: {
                gettolist(e) {
                    console.log(e)
                    api.openWin({
                        name: 'page1',
                        url: './oslist.html',
                        pageParam: {
                            id: e
                        }
                    });
                }
            },
            filters: {}

        })

        if ($api.getStorage('token')) {
            getPageInit();
            tad_os();
        } else {
            out();
            // alert("token获取失败");
            openWin('login', null, false);
            api.closeFrame();
        }

        //载入美洽客服
        mq = api.require('meiQiaPlus');
        initHeard();
        _downRefresh(function() {
            getPageInit();
            tad_os();
            api.refreshHeaderLoadDone();
        });
        // api.addEventListener({
        //     name: 'viewappear'
        // }, function(ret, err) {
        //     getPageInit();
        // });
        var slide3 = new auiSlide({
                container: document.getElementById("aui-slide3"),
                "height": 30,
                "speed": 500,
                "autoPlay": 3000, //自动播放
                "loop": true,
                "pageShow": true,
                "pageStyle": 'line',
                'dotPosition': 'center'
            })
        api.addEventListener({
            name: 'appintent'
        }, function(ret, err) {
            var appParam = ret.appParam;
            // alert(appParam.udid)
            if (!appParam.udid) {
                alert('请先获取UDID')
            } else {
                _ajax("user/setUdid", {
                    udid: appParam.udid
                }, function(res, err) {
                    if (res) {
                        console.log('518'+JSON.stringify(res));
                        if (res.errCode == 1) {
                            getPageInit()
                        } else if (res.errCode == -1) {

                        } else {

                        }
                    } else {
                        console.log('527'+JSON.stringify(err))
                    }
                })
            }
        });
        // var browser = api.require('webBrowser');
        // browser.historyBack(
        //     function(ret, err) {
        //         console.log(JSON.stringify(ret))
        //         if (!ret.status) {
        //             api.closeWin();
        //         }
        //     }
        // );
    };

    function tad_os() {
        _ajax("index/notice", {}, function(res, err) {
            if (res) {
                // vm.oslist = res.data;
                console.log(JSON.stringify(res))
                var scrollData = res.data
                if (scrollData != null) {
                    console.log(JSON.stringify(scrollData))
                    var item1 = scrollData[Math.floor(Math.random() * scrollData.length)]
                    var item2 = scrollData[Math.floor(Math.random() * scrollData.length)]
                    var item3 = scrollData[Math.floor(Math.random() * scrollData.length)]
                    var item4 = item1
                    vm.oslist = {
                        item1,
                        item2,
                        item3,
                        item4
                    }
                    console.log(JSON.stringify(vm.oslist));
                }
            } else {
                _msg("网络错误");
            }
        })
    }

    function openMq() {
        var userInfo = $api.getStorage('user');
        console.log('userInfo:::::'+JSON.stringify(userInfo))
        tapService(userInfo.id);
    }

    //获取首页信息
    function getPageInit() {
      api.parseTapmode();
        _ajax("index/income", {}, function(res, err) {
            if (res) {
                if (res.errCode == 1) {
                    console.log('571'+JSON.stringify(res))
                    udid_ = res.data.udid
                    MtId_ = res.data.Mtid
                    MtIDUser_ = res.data.uid
                    AppKey_ = res.data.Mtkey
                    // alert(udid + '-' + MtIDUser + '-' + MtId + '-' + AppKey)
                    var info = res.data;
                    if (info.mqkey != '')
                        initServer(info.mqkey);
                    if (info.todat_money != null && info.todat_money != '') {
                        $("#tod_money").html(Number(info.todat_money).toFixed(2)); //今日收益
                    }
                    if (info.sum_money != null && info.sum_money != '') {
                        $("#money span").eq(0).html(Number(info.sum_money).toFixed(2) + "元");
                    }
                    if (info.user_money != null && info.user_money != '') {
                        $("#money span").eq(1).html(Number(info.user_money).toFixed(2) + "元");
                    }
                } else if (res.errCode == -1) {
                    // alert("用户获取失败");
                    openWin('login');
                } else {
                    _msg(res.msg);
                }
            } else {
                _msg("网络错误");
            }
        })
    };

    function gogame() {
        console.log('602'+udid_ + '-' + MtIDUser_ + '-' + MtId_ + '-' + MtIDUser_ + '-' + AppKey_)
        if (!udid_) {
            jumpUDID()

        } else {
            var browser = api.require('webBrowser');
            var idfa = api.require('idfa');
            idfa.getIDFA(function(ret, err) {
                if (ret.status) {
                    // api.alert({
                    //     msg: ret.value
                    // });
                    console.log('确认'+udid_)
                    idfa_= ret.value
                    console.log(idfa_)
                    var MobileModel = api.deviceModel;
                    var SysVer = api.systemVersion;
                    var MtIDUser = MtIDUser_
                    var MtId = MtId_
                    var AppKey = AppKey_
                    var UDID = udid_
                    var sign = md5($.base64.encode(`${idfa_}#${MobileModel}#${MtIDUser}#${MtId}#${SysVer}#${UDID}#${AppKey}`))
                    var sign_ = `${idfa_}#${MobileModel}#${MtIDUser}#${MtId}#${SysVer}#${UDID}#${AppKey}`
                    console.log('sign_:'+sign_)
                    browser.open({
                        titleBar: {
                            bg: '#fff',
                            textColor: '#333'
                        },
                        url: `https://app.91taojin.com/?MtId=${MtId}&IDFA=${idfa_}&MtIDUser=${MtIDUser}&MobileModel=${MobileModel}&SysVer=${SysVer}&UDID=${UDID}&sign=${sign}`
                    });
                    // browser.openView({
                    //     url: `https://app.91taojin.com/?MtId=${MtId}&IDFA=${idfa_}&MtIDUser=${MtIDUser}&MobileModel=${MobileModel}&SysVer=${SysVer}&UDID=${UDID}&sign=${sign}`,
                    //     rect:{
                    //         x:0,
                    //         y:api.safeArea.top,
                    //         w:'auto',
                    //         h:'auto'
                    //     }
                    // }, function(ret, err){
                    //
                    //
                    // });



                } else {
                    // api.alert({
                    //     msg: err.code + ' ' + err.msg
                    // });
                }
            });

        }
    }

    function getUDID() {
        api.download({
            url: 'http://123.1.189.113/mobileconfig',
            report: true,
            cache: true,
            allowResume: true
        }, function(ret, err) {
            if (ret.state == 1) {
                alert('下载成功')
            } else {
                alert(json.stringify(err))
            }
        });
    }

    function jumpUDID() {
        api.alert({
            title: '提醒',
            msg: '为验证设备唯一性 保证任务顺利进行 首次需根据提示按顺序完成安装 现前往安装界面',
        }, function(ret, err) {
            if(ret){
              var token = $api.getStorage('token')
              if (token) {
                  api.openApp({
                      iosUrl: 'http://123.1.189.113/udid/index.php',
                  });
              } else {
                  out();
                //   alert("udid获取失败")
                  openWin('login', null, false);
                  api.closeFrame();
              }
            }
        });


    }
    function opentrWin(){
      if (!udid_) {
          console.log('再确认'+udid_)
          jumpUDID()
      }else{
        api.openWin({
            name: 'trial_task',
            url: './trial_task.html',
            pageParam: {
                name: 'test'
            }
        });

      }
    }
</script>

</html>
